<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>04运算符</title>
</head>
<body>
<script>
    //除法会显示实际的运算结果
    console.log(3/2);
    console.log(4/2);

    let a = 1;
    let b = true;
    //松散比较运算符,true,只比较值 Number(true)=1
    console.log(a == b);
    //严格比较运算符,false,先比较类型,再比较值 number≠boolean
    console.log(a === b);

    //0 null undefined '' NaN 转为Boolean都是false
    console.log(Boolean(0));
    console.log(Boolean(null));
    console.log(Boolean(undefined));
    console.log(Boolean(''));
    console.log(Boolean(NaN));//Not a Number

    // 1/0得到Infinity  0/0得到NaN

    console.log(3>10);//false
    console.log('3'<10);//true 会把'3'转为3再比较数字
    //只有两边都是字符串,才比较字符串的编码值
    console.log('3'>'10');//51>49 true
    //charCodeAt()查看当前字符的编码值
    console.log('3'.charCodeAt());//51
    console.log('10'.charCodeAt());//49
    console.log('超'>'博');
    console.log('超'.charCodeAt());
    console.log('博'.charCodeAt());

    //三目运算符  1 ? 2 : 3
    let c = 0;
    console.log( c==0 ? 'YES' : 'NO');//'YES'
    //=是赋值符号,给c赋值为0,转为布尔是false,所以取3号位置的值'NO'
    console.log( c=0 ? 'YES' : 'NO');//'NO'
</script>
</body>
</html>